//get请求获取个人信息
$(function () {
    console.log(localStorage.getItem('token'));
    axios({
        method: 'get',
        url: '/my/userinfo',
    })
        .then(res => {
            if (res.data.status == 0) {
                rendering(res.data.data)
            }
        })
})


//渲染获取的个人信息
function rendering(data) {
    var uname = data.nickname||data.username
    $('#welcome').text(`${uname}`)
    $('.text-avatar').text(uname.substr(0,1))
}



$('#btnLogout').on('click',function () {
    console.log('点击率');
    layer.confirm('是否退出登录', {icon: 3, title:'提示'}, function(index){
        //do something
        localStorage.removeItem('token')
        location.href = 'login.html'
        layer.close(index);
      });
})